package sanglh.edu.hsphysics.main;

import java.util.ArrayList;

import sanglh.edu.hsphysics.R;
import sanglh.edu.hsphysics.base.BazeItem;
import sanglh.edu.hsphysics.formulas.FormulaItem;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;

public class FragmentUpperHighSchool extends FragmentNavigationDrawerItem {
	private static final String RES_NAME = "file_page";

	public FragmentUpperHighSchool() {
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_upper_highschool,
				container, false);
		loadData(rootView);
		return rootView;
	}

	@Override
	public String getTitle() {
		return getString(R.string.uper_high_school);
	}

	private void loadData(View view) {
		GridView advance = (GridView) view.findViewById(R.id.gv2);
		GridView basic = (GridView) view.findViewById(R.id.gv);
		ArrayList<BazeItem> advItems = new ArrayList<BazeItem>();
		advItems.add(new FormulaItem(R.drawable.ic_physic_10_advance,
				getResources().getInteger(R.integer.physics_10_advance_pages),
				RES_NAME, String.format("%s %s", getString(R.string.physics),
						"10")));
		advItems.add(new FormulaItem(R.drawable.ic_physic_11_advance,
				getResources().getInteger(R.integer.physics_11_advance_pages),
				RES_NAME, String.format("%s %s", getString(R.string.physics),
						"11")));
		advItems.add(new FormulaItem(R.drawable.ic_physic_12_advance,
				getResources().getInteger(R.integer.physics_12_advance_pages),
				RES_NAME, String.format("%s %s", getString(R.string.physics),
						"12")));
		ArrayList<BazeItem> basItems = new ArrayList<BazeItem>();
		basItems.add(new FormulaItem(R.drawable.ic_physic_10, getResources()
				.getInteger(R.integer.physics_10_basic_pages), RES_NAME, String
				.format("%s %s %s", getString(R.string.physics), "10",
						getString(R.string.advance))));
		basItems.add(new FormulaItem(R.drawable.ic_physic_11, getResources()
				.getInteger(R.integer.physics_11_basic_pages), RES_NAME, String
				.format("%s %s %s", getString(R.string.physics), "11",
						getString(R.string.advance))));
		basItems.add(new FormulaItem(R.drawable.ic_physic_12, getResources()
				.getInteger(R.integer.physics_12_basic_pages), RES_NAME, String
				.format("%s %s %s", getString(R.string.physics), "12",
						getString(R.string.advance))));
		advance.setAdapter(new MenuAdapter(getActivity(), advItems,
				R.layout.row_book));
		basic.setAdapter(new MenuAdapter(getActivity(), basItems,
				R.layout.row_book));
		advance.setOnItemClickListener(this);
		basic.setOnItemClickListener(this);
	}

}
